<?php

namespace Cpadmin\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController {
protected $UserTable;
    public function getUserTable() {
        if (!$this->UserTable) {
            $sm = $this->getServiceLocator();
            $this->UserTable = $sm->get('Cpadmin\Model\UserTable');
        }
        return $this->UserTable;
    }

    public function indexAction() {

        if (isset($_POST["actiondo"])) {
            if ($_POST["actiondo"] == "checklogin") {
                $username = addslashes(trim($_POST["username"]));
               
                $passwprd = md5(addslashes(trim($_POST["password"])));
                $login = $this->getUserTable()->checklogin($username, $passwprd);
               // print_r($login);
                $rul=WEB_PATH."superadmin";
                if ($login != null) {
                    echo "loginOk*codebyduypc*".$rul;
                } else {
                    echo "loginfail*codebyduypc*Fail";
                }
                die;
            }
        }
    }

}
